package priv.hehe.controller;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import priv.hehe.util.JdbcUtil;
import priv.hehe.util.ResultObject;
//+-------------+---------------+------+-----+---------+----------------+
//| Field       | Type          | Null | Key | Default | Extra          |
//+-------------+---------------+------+-----+---------+----------------+
//| zwid        | int(11)       | NO   | PRI | NULL    | auto_increment |
//| flname      | varchar(200)  | YES  |     | NULL    |                |
//| money       | double        | YES  |     | NULL    |                |
//| zhangHu     | varchar(100)  | YES  |     | NULL    |                |
//| createtime  | date          | YES  |     | NULL    |                |
//| description | varchar(1000) | YES  |     | NULL    |                |
//+-------------+---------------+------+-----+---------+----------------+
//6 rows in set (0.01 sec)
public class AddGuPiaoHandler extends HttpServlet{

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		try {
			String parameter = req.getParameter("flname");
			if(parameter==null||(parameter.isEmpty())){//验证flname不能为空
				ResultObject setMsg = ResultObject.getResult().setStatus(false).setMsg("flname不能为空");
				resp.getWriter().print(JSON.toJSONString(setMsg));
				return;
			}
			Integer result = JdbcUtil.excute("insert into gjp_zhangwu values(null,?,?,?,?,?)", 
					parameter,
					req.getParameter("money"),
					req.getParameter("zhangHu"),
					new Date(),
					req.getParameter("description")
						);
			resp.getWriter().print(result);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	
	
}
